package cl.sujey.utils;

import static org.junit.Assert.*;

import org.junit.Assert;
import org.junit.Test;

public class ArrayUtilsTest {
	
	@Test
	public void testIsPalindromo01() {
		int[] aNonPalindromeArray = {1, 3, 4};
		
		Assert.assertFalse(ArrayUtils.isPanidromo(aNonPalindromeArray));
	}
	
	@Test
	public void testIsPalindromo02() {
		int[] palindromoArray = {1,2,3,2,1};
		
		Assert.assertTrue(ArrayUtils.isPanidromo(palindromoArray));
	}
	
	@Test
	public void testIsPalindromo03() {
		int[] miniArray = { 1 };
		
		Assert.assertFalse(ArrayUtils.isPanidromo(miniArray));
	}
	
	@Test
	public void testSonIguales() {
		int[] a = { 1, 2 };
		int[] b = { 1, 2 };
		
		Assert.assertTrue(ArrayUtils.sonIguales(a, b));
	}
	
	@Test
	public void testSonIguales02() {
		int[] a = { 1 };
		int[] b = { 1 };
		
		Assert.assertTrue(ArrayUtils.sonIguales(a, b));
	}

	@Test
	public void testSonIguales03() {
		int[] a = { 2 };
		int[] b = { 1 };
		
		Assert.assertFalse(ArrayUtils.sonIguales(a, b));
	}

	@Test
	public void testSonIguales04() {
		int[] a = {  };
		int[] b = {  };
		
		Assert.assertTrue(ArrayUtils.sonIguales(a, b));
	}
	
	@Test
	public void testMultiply01() throws Exception {
		double array1[] = {1};
		double array2[] = {2};
		
		assertEquals(2, ArrayUtils.multiply(array1, array2), 0);
	}
	
	@Test
	public void testMultiply02() throws Exception {
		double array1[] = {2,4};
		double array2[] = {3,5};
		
		assertEquals(26, ArrayUtils.multiply(array1, array2), 0);
	}

}